from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Book(Item):
    def __init__(self):
        Item.__init__(self, "Book")    # do basic initialization for every item
        self.read_book = False
        
        # build list of actions
        self.add_action(ReadtheBook)
    
    def get_description(self):
        return "Game of Thrones book"
    def get_image(self):
        return "gameofthrones.jpg"
# define actions for this item

class ReadtheBook(Action):
    def __init__(self):
        Action.__init__(self, "read_the_book")    # do basic initialization for every action
        self.isItemAction=True
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Read the book"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if not self.item.read_book:
            self.item.read_book = True
            set_cutscene("The book will help you answer questions.")
        return
    
    def is_enabled(self):
        if self.item.read_book:
            return False
        else:
            return True